package com.enqualcomm.kids.mvp.login.phone.model;

import com.enqualcomm.kids.mvp.NetworkModel;
import com.enqualcomm.kids.mvp.login.phone.presenter.onLoginListener;

import java.util.concurrent.TimeUnit;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;

/**
 * Created by Administrator on 2016/9/12.
 */
public class PhoneLoginModelImpl extends NetworkModel implements PhoneLoginModel {
    @Override
    public void Login(String username, String password, String country, final onLoginListener listener) {
        //TODO 模拟登录
        Observable.timer(2, TimeUnit.SECONDS)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<Long>() {
                    @Override
                    public void call(Long aLong) {
                        listener.success(null);
                    }
                });

//        LoginParams params = new LoginParams(username, password, country);
//        loadDataFromServer(new SocketRequest<LoginResult>(params, new NetworkListener<LoginResult>() {
//            @Override
//            public void onError(VolleyError error) {
//                listener.failed(100000, R.string.network_error);
//            }
//
//            @Override
//            public void onSuccess(LoginResult response) {
//                if (response.code == 0) {
//                    listener.success(response);
//                } else {
//                    listener.failed(response.code, response.desc);
//                }
//            }
//        }));
    }
}
